#define DEBUG
#include <cstdio>
#include <cstring>

using namespace std;

const int maxn=50, maxl=20, mods=990804011;

static long long f[maxl+1][28][maxn+1][maxn+1];

void initSolve() {
  memset(f, 255, sizeof f);
}

long long solve(int p, int c, int l, int r, int s[][maxl+1]) {
  if (f[p][c][l][r]>=0) {
    return f[p][c][l][r];
  }
  f[p][c][l][r] = (l>r || p>=maxl);
  bool stop_flag=c>26 || l>r || p>=maxl;
  for (int i=l; i<=r && !stop_flag; i++) {
    stop_flag = s[i][p]<c && s[i][p]>=0;
  }
  if (stop_flag) {
    return f[p][c][l][r];
  }

  f[p][c][l][r] = solve(p, c+1, l, r, s);
  bool no_seq = true;
  for (int i=l; i<=r; i++) {
    // if (i!=l && ((s[i][p]>=0 && s[i][p]<=s[i-1][p]) || (s[i][p]<0 && c<=s[i-1][p]))) {
    //   break;
    // }
    no_seq = no_seq && s[i][p]>=0;
    if ((c || no_seq) // && (s[i][p]<0 || s[i][p]<c+1)
	) {
      f[p][c][l][r] = (f[p][c][l][r]+solve(p+1, 0, l, i, s)*solve(p, c+1, i+1, r, s)%mods)%mods;
    }
  }
  return f[p][c][l][r]; 
}

int main() {
  freopen("b.in", "r", stdin);
  freopen("b.out", "w", stdout);

  static int s[maxn+1][maxl+1];
  int n;
  scanf("%d", &n);
  for (int i=1; i<=n; i++) {
    static char temp[maxl+1];
    scanf("%s", temp);
    for (int j=0; temp[j]!='\0'; j++) {
      if (temp[j]!='?') {
	s[i][j] = temp[j]-'a'+1;
      } else {
	s[i][j] = -1;
      }
    }
  }

  initSolve();

  printf("%lld", solve(0, 1, 1, n, s));

  fclose(stdin);
  fclose(stdout);
  return 0;
}
